package com.api.user.getuser;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IUserApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.ObjectResultApi;
import com.zyncro.api.model.UserApi;

@ContextConfiguration(locations = { "classpath:/user/user-context.xml" })
public class GetUserNotContact extends AbstractApiTest {

	@Value("#{org_users[mainAdmin].appId}")
	private String userId;

	@Value("#{org_users[mainAdmin].password}")
	private String userPassword;

	@Value("#{org_users[notContact].appId}")
	private String targetUserUrn;

	@BeforeClass
	public void setUpVariables() {

		getApi().login(userId, userPassword);
	}

	@Test
	public void testGetContacts() throws ZyncroApiException {

		boolean onlyShort = false;

		ObjectResultApi<? extends UserApi> result = getApi().getService(IUserApiService.class).getUser(targetUserUrn, onlyShort);
		UserApi user = result.getObject();

		Assert.assertEquals(user.getAppId(), targetUserUrn);
	}

	@Test
	public void testGetContactsOnlyShort() throws ZyncroApiException {

		boolean onlyShort = true;

		ObjectResultApi<? extends UserApi> result = getApi().getService(IUserApiService.class).getUser(targetUserUrn, onlyShort);
		UserApi user = result.getObject();

		Assert.assertEquals(user.getAppId(), targetUserUrn);
	}
}
